//
//  PeiHuFenXingViewController.m
//  XiangMu
//
//  Created by 康世标 on 15/7/17.
//  Copyright (c) 2015年 康世标. All rights reserved.
//

#import "PeiHuFenXingViewController.h"
#import "Header.h"
#import "UIButton+WebCache.h"
#import "Masonry.h"
#import "SVPullToRefresh.h"
@interface PeiHuFenXingViewController ()

@end

@implementation PeiHuFenXingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     self.tabBarController.tabBar.hidden=YES;

    //返回
    UIButton *fanHuiBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    fanHuiBtn.frame=CGRectMake(20, 20, 10, 20);

    [fanHuiBtn setBackgroundImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    
    [fanHuiBtn addTarget:self action:@selector(FanHui) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *barFanHui = [[UIBarButtonItem alloc]initWithCustomView:fanHuiBtn];
    self.navigationItem.leftBarButtonItem = barFanHui;
    //标题
    self.title =@"陪护分享";
    
       //医院名字
    //
    yiYuanMingZi = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW/2+40, 0, kScreenW/2-90, 40)];
    yiYuanMingZi.text = @"浙江省人民医院";
    yiYuanMingZi.font = [UIFont systemFontOfSize:12];
    yiYuanMingZi.textColor = [UIColor whiteColor];
    yiYuanMingZi.textAlignment = NSTextAlignmentRight;

    UIBarButtonItem * ba = [[UIBarButtonItem alloc]initWithCustomView:yiYuanMingZi];
    
    UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(yiYuanMingZi.frame.origin.x+yiYuanMingZi.frame.size.width+5, 10, 15, 7)];
    [btn setBackgroundImage:[UIImage imageNamed:@"10"] forState:UIControlStateNormal];

    
    [btn addTarget:self action:@selector(XuanZeYiYuan) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem*bar=[[UIBarButtonItem alloc]initWithCustomView:btn];
    
    self.navigationItem.rightBarButtonItems = @[bar,ba];
    

      //发分享
    UIButton*faFenXiangBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    faFenXiangBtn.frame=CGRectMake(0, kScreenH-44-64, kScreenW, 44);
    [faFenXiangBtn setBackgroundImage:[UIImage imageNamed:@"fabufenxiang"] forState:UIControlStateNormal];
    [faFenXiangBtn addTarget:self action:@selector(faFenXing) forControlEvents:UIControlEventTouchUpInside];
    
   
    tableview = [[UITableView alloc]initWithFrame:CGRectMake(0,0,kScreenW, kScreenH-44) style:UITableViewStylePlain];
    
    tableview.delegate = self;
    
    tableview.dataSource = self;
    tableview.separatorStyle = UITableViewCellSelectionStyleNone;
    tableview.backgroundColor = CL_efeff4;
    
    [self.view addSubview:tableview];
    [self.view addSubview:faFenXiangBtn];
    caiDanTableView = [[UITableView alloc]initWithFrame:CGRectMake(2, 0, kScreenW-4, 250) style:UITableViewStyleGrouped];
    caiDanTableView.layer.borderWidth=.7f;
    caiDanTableView.delegate = self;
    caiDanTableView.dataSource =self;
    caiDanTableView.tag= 100;

    caiDanTableView.hidden=YES;
    
    [self.view addSubview:caiDanTableView];
    
    self.datasArr = [[NSMutableArray alloc]initWithCapacity:0];
    
//    self.hospitalCommunityArr = [[NSMutableArray alloc]initWithCapacity:0];
    
    self.dic = [[NSMutableDictionary alloc]initWithCapacity:0];
    
    self.shuaiXuanDic = [[NSMutableDictionary alloc]initWithCapacity:0];
    
    i=1;
    
    [self.dic setValue:@(i) forKey:@"page"];
    
    [self.dic setValue:@(10) forKey:@"rows"];
    
    __weak PeiHuFenXingViewController * wself = self;
    
    
    //上推加载更多
    [tableview addInfiniteScrollingWithActionHandler:^{
        
       [wself performSelector:@selector(JiaZaiGengDuo) withObject:wself afterDelay:1];

    }];
    //下拉刷新
    [tableview addPullToRefreshWithActionHandler:^{
        
        [wself performSelector:@selector(XiaLaShuaXin) withObject:wself afterDelay:1];
    }];
    
    [self PorgressH];

    [self QingQiu];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jiajia) name:@"jiajia" object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jianjian) name:@"jianjian" object:nil];

}
- (void)XiaLaShuaXin{
    [self.datasArr removeAllObjects];
    
    [self.dic setObject:@(1) forKey:@"page"];
    [self QingQiu];
}
- (void)JiaZaiGengDuo{
    
    i++;
    
    [self.dic setObject:@(i) forKey:@"page"];
    
    [self QingQiu];
    
}
- (void)PorgressH{
    
   hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
   hud.labelText=@"数据加载中...";
    
    
    
}
- (void)QingQiu{

    [QingQiuShuJu HuoQuQuanBuFenXiang:self.dic HuiChuan:^(NSMutableArray *arr, BOOL isOK1)
    {
        
        if (isOK1) {
            
           [self.datasArr  addObjectsFromArray:[[arr valueForKey:@"data"]valueForKey:@"shares"]];
            
            self.hospitalCommunityArr = [[arr valueForKey:@"data"] valueForKey:@"hospitalCommunity"];
            
            
            
            hud.removeFromSuperViewOnHide =YES ;
            
            [hud hide:NO];
              tableview.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
            [tableview.infiniteScrollingView stopAnimating];
            
            [tableview.pullToRefreshView stopAnimating];
              yiYuanMingZi.text = [[[ self.hospitalCommunityArr valueForKey:@"hospitals"] objectAtIndex:0] valueForKey:@"name"];
             [tableview reloadData];
            [caiDanTableView reloadData];
            
        }
        else{
            
    
            [tableview.infiniteScrollingView stopAnimating];
            
            [tableview.pullToRefreshView stopAnimating];

       
            
            hud.mode=MBProgressHUDModeText;
            hud.labelText=@"网络连接失败";
            hud.removeFromSuperViewOnHide=YES;
            [hud hide:YES afterDelay:1.5];

        }
        
    }];
    
}
- (void)FanHui{
    self.tabBarController.tabBar.hidden=NO;
    [self.navigationController popViewControllerAnimated:YES];

}
-(void)XuanZeYiYuan{
    
    if (!isOK) {
         caiDanTableView.hidden=NO;
    }
   
    else{
        
        caiDanTableView.hidden=YES;
    }
    isOK = !isOK;
}
-(void)faFenXing{
//    FaFenXiangViewController*f=[[FaFenXiangViewController alloc]init];
    
    ReleaseController * re = [[ReleaseController alloc]init];
    
    re.hospitalCommunityArr = self.hospitalCommunityArr;
    
    [self.navigationController pushViewController:re animated:YES];
}
#pragma mark---UITableViewDataSource,UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView.tag==100)
    {
        
        if (!flag[section])
        {
            
            NSArray *arr =[self.hospitalCommunityArr valueForKey:section==0?@"hospitals":@"communitys"];
            
            return arr.count;
            
        }
        else
        {
            return 0;
        }
        
        
    }
    else{
         return self.datasArr.count;
    }
   
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    if (tableView.tag==100)
    {
        
        
        return 2;
    }
    else{
        
        return 1;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag==100) {
        
        static NSString * tab=@"";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:tab];
        if (!cell) {
            
            cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:tab];
            
        }
        
        
        if (indexPath.section==0)
        {
            
            cell.textLabel.text = [[[ self.hospitalCommunityArr valueForKey:@"hospitals"] objectAtIndex:indexPath.row] valueForKey:@"name"];
            
        }
        else{
            cell.textLabel.text = [[[ self.hospitalCommunityArr valueForKey:@"communitys"] objectAtIndex:indexPath.row] valueForKey:@"name"];
        }
        
        return cell;
        
    }
    else
    {
        FenXiangTableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"fenxiang"];
        if (!cell) {
            cell=[[[NSBundle mainBundle]loadNibNamed:@"FenXiangTableViewCell" owner:nil options:nil]lastObject];
        }
        
        if ([[[self.datasArr objectAtIndex:indexPath.row]valueForKey:@"url"] isEqualToString:@""])
        {
     
            NSArray * arr;
             [cell Commmend:arr];
        }
        else
        {
            NSString * url = [[self.datasArr objectAtIndex:indexPath.row] valueForKey:@"url"];
       
            
            
              NSArray * arr=[url componentsSeparatedByString:@","];
              [cell Commmend:arr];

        }
        
      
        
        NSArray *dataArr = [self.datasArr objectAtIndex:indexPath.row];
        
        cell.label1.text = [dataArr valueForKey:@"nickname"]==[NSNull null]?@"":[dataArr valueForKey:@"nickname"];
        
        cell.lable2.text = [self upDated:[[dataArr valueForKey:@"updated"]==[NSNull null]?@"":[dataArr valueForKey:@"updated"] longLongValue]];
        
        [cell.touXiang sd_setBackgroundImageWithURL:[NSURL URLWithString:[dataArr valueForKey:@"headImg"]==[NSNull null]?@"":[dataArr valueForKey:@"headImg"]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"like"]];
        
        NSLog(@"---%@",[dataArr valueForKey:@"headImg"]);
        
        cell.label3.text = [NSString stringWithFormat:@"       %@",[dataArr valueForKey:@"info"]==[NSNull null]?@"":[dataArr valueForKey:@"info"]];
        
        cell.lable4.text = [NSString stringWithFormat:@"%@",[dataArr valueForKey:@"repostCount"]==[NSNull null]?@"":[dataArr valueForKey:@"repostCount"]];
        
        cell.lable5.text = [NSString stringWithFormat:@"%@",[dataArr valueForKey:@"clickCount"]==[NSNull null]?@"":[dataArr valueForKey:@"clickCount"]];
        
        cell.lable6.text = [NSString stringWithFormat:@"%@",[dataArr valueForKey:@"commentCount"]==[NSNull null]?@"":[dataArr valueForKey:@"commentCount"]];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [cell.fanXiangBtn addTarget:self action:@selector(FenXiangClock:) forControlEvents:UIControlEventTouchUpInside];
        
        cell.fanXiangBtn.tag=indexPath.row;
        
        [cell.dianZanBtn addTarget:self action:@selector(dianZanBtnClock:) forControlEvents:UIControlEventTouchUpInside];
        
        cell.dianZanBtn.tag =indexPath.row;
        
        [cell.pingLun addTarget:self action:@selector(pingLunBtnClock:) forControlEvents:UIControlEventTouchUpInside];
        cell.pingLun.tag =indexPath.row;
        
        
        return cell;
        

    }
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    

    
    if (tableView.tag==100)
    {
        
        return 40;
    }
    else{
        
        if ([[[self.datasArr objectAtIndex:indexPath.row]valueForKey:@"url"] isEqualToString:@""]) {
//            NSArray *dataArr = [self.datasArr objectAtIndex:indexPath.row];
//            
//            NSString * hegi = [NSString stringWithFormat:@"       %@",[dataArr valueForKey:@"info"]==[NSNull null]?@"":[dataArr valueForKey:@"info"]];
//            [self getNString:hegi width:CGSizeMake(kScreenW-80, MAXFLOAT)];
            return 165;
        }
        NSArray * arr=[[[self.datasArr objectAtIndex:indexPath.row]valueForKey:@"url"] componentsSeparatedByString:@","];
        
        int x = (int)arr.count;

        if (x==7) {
            
            return 220+200;
        }
        return 220+10 *((x/4) + 1) + (x/4) *80;
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    if (tableView.tag==100) {
        
        return 35;
    }
    else
        
    {
        return 0;
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (tableView.tag!=100) {
        
        return nil;
        
    }
    UIView * view=nil;
    
    view = [[UIView alloc]initWithFrame:CGRectMake(2, 0, kScreenW-4, 40)];
    
    view.backgroundColor =CL_00cc85;
    
    UIButton * button=nil;
    button =[UIButton buttonWithType:UIButtonTypeCustom];
    
    [button.titleLabel setFont:[UIFont systemFontOfSize:15]];
    UIImageView * imageView=nil;
    
    imageView = [[UIImageView alloc]init];

    imageView.image = [UIImage imageNamed:@"jiaoge"];
    if (section==0) {
        
        [button setTitle:@"医院分享" forState:UIControlStateNormal];
              button.tag=0;
    }
    else{
        
        [button setTitle:@"社区分享" forState:UIControlStateNormal];
        button.tag=1;
    }
    
    [button addTarget:self action:@selector(btnClock:) forControlEvents:UIControlEventTouchUpInside];
    
    [view addSubview:button];
    [view addSubview:imageView];
    
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(view).with.offset(10);
        make.size.mas_equalTo(CGSizeMake(60, 40));
        
    }];
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        

        make.right.equalTo(button).with.offset(10);
        make.top.equalTo(view).with.offset(15);
        make.size.mas_equalTo(CGSizeMake(8, 8));
        
    }];
    
    if (flag[section]) {
        
        imageView.transform = CGAffineTransformMakeRotation(180*M_PI/180);
        
    }
    else{
        imageView.transform = CGAffineTransformMakeRotation(0);
    }
    
    return view;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (tableView.tag == 100)
    {
      
        NSString * str;
        
        if (indexPath.section==0)
        {
            
            str = [[[ self.hospitalCommunityArr valueForKey:@"hospitals"] objectAtIndex:indexPath.row] valueForKey:@"id"];
          yiYuanMingZi.text = [[[ self.hospitalCommunityArr valueForKey:@"hospitals"] objectAtIndex:indexPath.row] valueForKey:@"name"];
          

            
        }
        else{
            str= [[[ self.hospitalCommunityArr valueForKey:@"communitys"] objectAtIndex:indexPath.row] valueForKey:@"id"];
              yiYuanMingZi.text = [[[ self.hospitalCommunityArr valueForKey:@"communitys"] objectAtIndex:indexPath.row] valueForKey:@"name"];
        }

   
        
        [self.shuaiXuanDic setValue:@(indexPath.section+1) forKey:@"type"];
        
        [self.shuaiXuanDic setValue:@([str intValue]) forKey:@"id"];
        
        [self.shuaiXuanDic setValue:@(1) forKey:@"page"];
        
        [self.shuaiXuanDic setValue:@(10) forKey:@"rows"];
        
        [self ShaiXuan];
        
        caiDanTableView.hidden = YES;
        isOK=NO;
    }
    else{
        
        FenXiangXiangQingViewController * fen = [[FenXiangXiangQingViewController alloc]init];

        NSString *useString =[[self.datasArr objectAtIndex:indexPath.row]valueForKey:@"url"];
        
        if ([useString isEqualToString:@""]||useString ==nil) {
            
        }
        else{
            fen.imagesArr = [useString componentsSeparatedByString:@","];
            
        }
        
        fen.datasArr = [[NSMutableDictionary alloc]initWithDictionary:[self.datasArr objectAtIndex:indexPath.row]];
        
        self.indeRow = indexPath.row;
        
        [self.navigationController pushViewController:fen animated:YES];
    
    }
    
    
    
}
- (void)ShaiXuan{
    
   [self PorgressH];
    
   [self.datasArr removeAllObjects];
      ;
    [QingQiuShuJu ShaiXuanFenXiang:self.shuaiXuanDic HuiChuan:^(NSMutableArray *arr, BOOL isOK2)
    {
        
        
        if (isOK2)
        {
            [self.datasArr  addObjectsFromArray:[arr valueForKey:@"data"]];
            
            hud.removeFromSuperViewOnHide =YES ;
            
            [hud hide:NO];
            
            [tableview.infiniteScrollingView stopAnimating];
            
            [tableview.pullToRefreshView stopAnimating];
            [tableview reloadData];
        }
        else
        {
            [hud hide:YES];
            [tableview.infiniteScrollingView stopAnimating];
            
            [tableview.pullToRefreshView stopAnimating];
            
            hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            
            hud.mode=MBProgressHUDModeText;
            hud.labelText=[arr valueForKey:@"msg"]==[NSNull null]?@"网络连接超时": [arr valueForKey:@"msg"];
            
            hud.removeFromSuperViewOnHide=YES;
            
            [hud hide:YES afterDelay:1.5];
            
            [tableview reloadData];
        }
        
        
        
    
        
    }];
}
- (void)btnClock:(UIButton *)sender{
    
    flag[sender.tag] = !flag[sender.tag];
    

    
    [caiDanTableView reloadSections:[NSIndexSet indexSetWithIndex:sender.tag] withRowAnimation:UITableViewRowAnimationFade];
    
}

-(NSString *)upDated:(long long)str{
    

    NSDate * date = [NSDate dateWithTimeIntervalSince1970:str/1000];
    
    NSDateFormatter * dataFormatter = [[NSDateFormatter alloc]init];
    
    [dataFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    
    NSString * string= [dataFormatter stringFromDate:date];
    
    return string;
    
}
#pragma mark----分享
- (void)FenXiangClock:(UIButton *)button{

    KSActionSheet * sheet = [[KSActionSheet alloc]initWithActionSheet];
    sheet.delegate = self;
    [sheet show];
    
    self.buttonIndex = button.tag;
    
    
}
#pragma makr ----点赞
- (void)dianZanBtnClock:(UIButton *)button{
    
    if ([UserManager  login])
    {
        
        [[[UIAlertView alloc]initWithTitle:nil message:@"您还没有登陆" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil]show];
        
        return;
    }
    
    hud =[MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    hud.margin =20;
    
    
     NSDictionary *dataArr = [self.datasArr objectAtIndex:button.tag] ;
    
   [QingQiuShuJu FenXiangDianZan:[[NSUserDefaults standardUserDefaults] objectForKey:@"ID"] sheareId:[ dataArr valueForKey:@"id"] Blokc:^(NSDictionary *dic, BOOL isOK1)
    {
        if (isOK1)
        {

            
            if ([[dic valueForKey:@"status"] intValue]==200)
            {
                
                NSMutableDictionary * ddd =[NSMutableDictionary dictionaryWithDictionary:dataArr];
                
                NSInteger inte = [[dataArr valueForKey:@"clickCount"] integerValue];
                
                
                inte ++;
                
               [ ddd setValue:@(inte) forKey:@"clickCount"];
                
                [self.datasArr setObject:ddd atIndexedSubscript:button.tag];
                hud.mode = MBProgressHUDModeText;
                
                hud.labelText = @"已点赞";
                [hud hide:YES afterDelay:1];
                
                
                
            }
            else if ([[dic valueForKey:@"status"] intValue]==201){
                NSMutableDictionary * ddd =[NSMutableDictionary dictionaryWithDictionary:dataArr];
                
                NSInteger inte = [[dataArr valueForKey:@"clickCount"] integerValue];
                
                inte --;
                
                [ ddd setValue:@(inte) forKey:@"clickCount"];
                
                [self.datasArr setObject:ddd atIndexedSubscript:button.tag];
                
                hud.mode = MBProgressHUDModeText;
                hud.labelText = @"已取消点赞";
                [hud hide:YES afterDelay:1];
              


                
            }
            
           [tableview reloadData];
            
            
            
        }
        else{
            
            hud.mode = MBProgressHUDModeText;
            hud.labelText = @"网络连接失败";
            
            [hud hide:YES afterDelay:2];
            
        }
       
       
       
   }];
}
#pragma mark ---- 评论
- (void)pingLunBtnClock:(UIButton *)button{
    if ([UserManager  login])
    {
        
        [[[UIAlertView alloc]initWithTitle:nil message:@"您还没有登陆" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil]show];
        
        return;
    }

    FenXiangXiangQingViewController * fen = [[FenXiangXiangQingViewController alloc]init];
    
    NSString *useString =[[self.datasArr objectAtIndex:button.tag]valueForKey:@"url"];
    
    if ([useString isEqualToString:@""]) {
        
    }
    else{
        fen.imagesArr = [useString componentsSeparatedByString:@","];
        
    }
    
    fen.datasArr = [[NSMutableDictionary alloc]initWithDictionary:[self.datasArr objectAtIndex:button.tag]];
    
    self.indeRow = button.tag;
    

    fen.longVc = YES;
    [self.navigationController pushViewController:fen animated:YES];
    
}
#pragma mark---KSActionSheetDelegate

- (void)alertView:(KSActionSheet *)alertView clickedButtonAtIndexPantex:(NSInteger)buttonIndex{


    if (buttonIndex ==0) {
        
        return;
    }
    NSDictionary *dataArr = [self.datasArr objectAtIndex:self.buttonIndex];

    NSInteger  Id = [[dataArr valueForKey:@"id"] integerValue];
    
    
    
    WXMediaMessage *message = [WXMediaMessage message];

    
    message.title = @"爱陪护";
    message.description = @"爱陪护";
    [message setThumbImage:[UIImage imageNamed:@"Image_Icon"]];
    
    WXWebpageObject *ext = [WXWebpageObject object];
    ext.webpageUrl = [NSString stringWithFormat:@"%@%@?shareId=%ld",URL,URL_FENXING,(long)Id];
    
    message.mediaObject = ext;
    
    SendMessageToWXReq* req = [[SendMessageToWXReq alloc] init];
    req.bText = NO;
    req.message = message;
    req.scene = (int)buttonIndex -1;
    
    BOOL isok=   [WXApi sendReq:req];
    
    if (!isok) {
        [[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"未安装微信客户端" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil, nil] show];
        
    }
    

    
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    if (buttonIndex==0) {
        
        DengLuViewController * dl = [[DengLuViewController alloc]init];
        
        UINavigationController * nav =[[UINavigationController alloc]initWithRootViewController:dl];
        
        [self presentViewController:nav animated:YES completion:nil];
        
        
    }
}
#pragma mark --- 点赞 ++
- (void)jiajia{
    
//    NSLog(@"jia");
      NSDictionary *dataArr = [self.datasArr objectAtIndex:self.indeRow] ;
    NSMutableDictionary * ddd =[NSMutableDictionary dictionaryWithDictionary:dataArr];
    
    NSInteger inte = [[dataArr valueForKey:@"clickCount"] integerValue];
    
    inte ++;
    
    [ ddd setValue:@(inte) forKey:@"clickCount"];
    
    [self.datasArr setObject:ddd atIndexedSubscript:self.indeRow];
    
  
    
    
    [tableview reloadData];

}
#pragma mark --- 点赞 --
- (void)jianjian{
    
    
    NSDictionary *dataArr = [self.datasArr objectAtIndex:self.indeRow] ;
    NSMutableDictionary * ddd =[NSMutableDictionary dictionaryWithDictionary:dataArr];
    NSInteger inte = [[dataArr valueForKey:@"clickCount"] integerValue];
    
    inte --;
    
    [ ddd setValue:@(inte) forKey:@"clickCount"];
    
    [self.datasArr setObject:ddd atIndexedSubscript:self.indeRow];
    
    
    
    
    [tableview reloadData];
    
}
- (CGFloat )getNString:(NSString *)string width:(CGSize)make{
    
    CGRect  rect = [string boundingRectWithSize:make options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil];
    
    return rect.size.height;
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
